<template>
  <div style="height:100%;overflow-y:auto;">
    <div style="width:500px;">
      <span>阿里云存储账户配置</span>
      <el-form :model="oss" label-position="top" label-width="80px">
        <el-form-item label="keyid">
          <el-input v-model="oss.keyid"></el-input>
        </el-form-item>
        <el-form-item label="keysecret">
          <el-input v-model="oss.keysecret"></el-input>
        </el-form-item>
        <el-form-item label="endpoint">
          <el-input v-model="oss.endpoint"></el-input>
        </el-form-item>
        <el-form-item label="bucket">
          <el-input v-model="oss.bucket"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="resetOss">立即修改</el-button>
        </el-form-item>
      </el-form>
      <span>修改密码</span>
      <el-form :model="password" label-position="top" label-width="80px">
        <el-form-item label="新密码">
          <el-input type="password" v-model="password.password"></el-input>
        </el-form-item>
        <el-form-item label="确认密码">
          <el-input type="password" v-model="password.reppassword"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="updateP">修改密码</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import { getOssMsg, editAdminPassword, editOss } from "@/api/admin/user"
export default {
  data() {
    return {
      oss: {
        keyid: "",
        keysecret: "",
        endpoint: "",
        bucket: ""
      },
      password: {
        password: "",
        reppassword: ""
      },
    }
  },
  created() {
    getOssMsg({}, (res) => {
      if (res.code == 200) {
        this.oss = res.data
      }
    })
  },
  methods: {
    resetOss() {
      editOss(this.oss, (res) => {

      }, true)
    },
    updateP() {
      editAdminPassword(this.password, (res) => {
        if (res.code == 200) {
          this.password = {
            password: "",
            reppassword: ""
          }
        }
      }, true)
    }
  }
}
</script>

<style lang="less" scoped>
</style>